Skip to content

Add multidimensional sweep coordinates and measurement results - #687

Draft
Abse2001 wants to merge 2 commits into
tscircuit:mainfrom
Abse2001:codex/analog-measurement-results
Draft

Add multidimensional sweep coordinates and measurement results#687
Abse2001 wants to merge 2 commits into
tscircuit:mainfrom
Abse2001:codex/analog-measurement-results

Conversation

@Abse2001

@Abse2001 Abse2001 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add ordered simulation_parameter_sweep_coordinates to analysis results while retaining the singular coordinate for one-dimensional compatibility
  • add the RFC-defined aggregated simulation_measurement_result element
  • keep every Circuit JSON interface and Zod object flat and explicit; no generated, extended, merged, or programmatically constructed result types
  • validate finite scalar measurements and alignment between measurement values and sweep coordinate sets
  • expose the new result through the simulation exports and AnyCircuitElement
  • regenerate the Circuit JSON documentation and add focused schema tests

RFC context

This implements the Circuit JSON portion of the merged SPICE Simulation Analyses, Stimulus, and Measurements RFC, specifically the multidimensional sweep relationships and measurement-result contract introduced through tscircuit/rfc#11.

The RFC specifies that multidimensional analysis results carry an ordered simulation_parameter_sweep_coordinates array, while one-dimensional results retain simulation_parameter_sweep_coordinate. It also specifies one simulation_measurement_result per measurement, with measurement_values aligned to simulation_parameter_sweep_coordinate_sets in Cartesian-product order.

The immediate use case is a TPS63802 load-regulation simulation: input voltage and load current form a two-dimensional sweep, and each run contributes one scalar regulation measurement. The schemas in this PR remain generic and are not tied to that device.

This PR intentionally covers only the Circuit JSON contract. The corresponding props, core execution, and Circuit-to-SVG rendering work will follow in their respective repositories.

Implementation conventions

This implementation follows the tscircuit code handbook and its API design guidance: prioritize readability, keep API objects flat, and preserve snake_case for Circuit JSON.

Each of the eight analysis-result interfaces and Zod schemas declares its sweep-coordinate fields directly. Shared type extension, schema composition, programmatic field construction, and generalized coordinate-validation helpers are intentionally avoided so the public types remain simple to read in both source and generated documentation.

Compatibility

  • existing one-dimensional sweep results remain valid
  • multidimensional results use an ordered coordinate array with at least two entries
  • measurement results without a parameter sweep contain exactly one scalar value
  • measurement values and coordinate sets must have matching lengths

Validation

  • bun test - 291 tests passed
  • bun run build
  • bunx tsc --noEmit
  • bun run lint:zod
  • bun run check-snake-case
  • bun run generate-docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant